<div style="width: 100%;text-align: center;background-image: url(images/timg.jpg);">
    <div style="height:240px;width: 400px;margin: auto;padding: 20px; ">
        <img width="50%" style="float: left;border-radius: 200px;border: solid white 5px;" src="<?=$info['wx_images']?>">
        <div style="float: left;margin-left:50px;margin-top: 100px;">
            <h2>
                <?=$info['wx_name']?>
            </h2>
        </div>
    </div>
</div>
<div style="padding: 50px;width: 100%;">
    <style>
        th{
            text-align: center;
        }
        td{
            text-align: center;
            vertical-align:middle;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
    </style>
    <table class="table" style="border: 1px white solid;">
        <thead>
            <th>购买订单号</th>
            <th>购买人微信头像</th>
            <th>购买人微信姓名</th>
            <th>购买商品图片</th>
            <th>购买商品名称</th>
            <th>购买时间</th>
            <th>购买数量</th>
            <th>获得返利</th>
            <th>是否已支付</th>
        </thead>
        <tbody>
            <?php foreach($shareRebARR as $k=>$v) {?>
                <tr>
                    <td><?=$v['order_sn']?></td>
                    <td><img width="60px" src="<?=$v['buyer_images']?>" onerror="this.src='images/qqfenx.png'"></td>
                    <td><?=$v['buyer_name']?></td>
                    <td><img width="60px" src="../<?=$v['goods_image']?>"></td>
                    <td><?=$v['goods_name']?></td>
                    <td><?=date('Y-m-d H:i:s',$v['created_at'])?></td>
                    <td><?=$v['goods_number']?></td>
                    <td><?=$v['reb_money']?></td>
                    <td><?php if($v['is_payed']) { ?>
                        <button class='btn btn-default' disabled='disabled'>已支付</button>
                        <?php } else { ?>
                        <button data-money=<?=$v['reb_money']?> data-srid=<?=$v['share_reb_id']?>  class='btn-success' onclick="javascript:toPer(this)" data-userid=<?=$v['user_id']?> >
                            去支付
<!--                            <a href="?r=orders/ordergoods/paytoper&userid=--><?//=$v['user_id']?><!--&reb_money=--><?//=$v['reb_money']?><!--">去支付</a>-->
                        </button>
                        <?php } ?>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<!--<script src="https://cdn.bootcss.com/bootstrap-modal/2.2.6/js/bootstrap-modal.min.js"></script>-->

<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    模态框（Modal）标题
                </h4>
            </div>
            <div class="modal-body">
                请输入密文
                <input type="text" id="token">
                <input type="hidden" id="_csrf" value="<?php Yii::$app->request->getCsrfToken()?>">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" onclick="javascript:postTo()">
                    提交更改
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    var userid='';
    var money='';
    var srid = '';
    function toPer(self){
        var dataset = $(self).context.dataset;
         userid = dataset.userid;
         money = dataset.money;
        srid = dataset.srid;
        $('#myModal').modal({
            keyboard: true
        })
    }

    function postTo()
    {
        var token = $("#token").val();
        var _csrf = $("#_csrf").val();
        $.ajax({
            url: '?r=orders/ordergoods/paytoper',
            type: 'post',
            data: {_csrf:_csrf,userid:userid,reb_money:money,token:token,srid:srid},
            success: function (data) {
                var massage = eval('('+data+')');
                if(massage[0]){
                    window.location.reload()
                } else{
                    alert(massage[1]);
                }
            }
        });
    }
</script>

